package com.baidu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baidu.entity.PageResult;
import com.baidu.entity.QueryPageBean;
import com.baidu.mapper. EvaluationMapper;
import com.baidu.pojo. Evaluation;
import com.baidu.service. EvaluationService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass =  EvaluationService.class)
@Transactional
public class EvaluationServiceImpl implements EvaluationService {
	@Autowired
	private  EvaluationMapper  evaluationMapper;


	@Override
	public PageResult pageQuery(QueryPageBean queryPageBean) {
		PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());//会自动的添加limit关键字

		//使用分页助手之后，limit0,10 。这个条件就不用我们写了。我们只用写 limit之前的语句

		Page< Evaluation> page=  evaluationMapper.pageQuerybyCondition(queryPageBean.getQueryString());//该Page对象是分页助手帮助我们封住的对象。

		PageResult pageResult = new PageResult(page.getTotal(),page.getResult());

		return pageResult;
	}

	@Override
	public void delete(Integer id) {

		 evaluationMapper.delete(id);
	}

	@Override
	public void add( Evaluation  evaluation) {
		 evaluationMapper.add( evaluation);

	}

	@Override
	public  Evaluation findById(Integer id) {
		return  evaluationMapper.findById(id);
	}

	@Override
	public void edit( Evaluation  evaluation) {
		 evaluationMapper.edit( evaluation);
	}


}
